package com.yt.order.provider.service.impl;

import com.yt.core.dao.filter.DynamicSQLFilterImpl;
import com.yt.core.dao.filter.QueryFilter;
import com.yt.core.service.GenericServiceImpl;
import com.yt.order.api.interfaces.InstitutionImageService;
import com.yt.order.api.model.InstitutionImage;
import com.yt.order.provider.dao.InstitutionImageDao;

import java.util.List;

public class InstitutionImageServiceImpl extends GenericServiceImpl<InstitutionImage, Long> implements InstitutionImageService {
	private InstitutionImageDao dao;

	public InstitutionImageServiceImpl(InstitutionImageDao dao) {
		super(dao);
		this.dao = dao;
	}

	@Override
	public List<InstitutionImage> getByInstitution(Long institutionId, Long institutionBranchId) {
		QueryFilter filter = new DynamicSQLFilterImpl();
		filter.addFilter("Q_idInstitution_L_EQ", institutionId + "");
		if (institutionBranchId != null) {
			filter.addFilter("Q_idInstitutionBranch_L_EQ", institutionBranchId + "");
		}
		return dao.find(filter);
	}

	@Override
	public void removeByInstitution(Long institutionId, Long institutionBranchId) {
		dao.removeByInstitution(institutionId, institutionBranchId);
	}
}
